package com.wwy.config;

import org.springframework.amqp.core.*;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * @author 王伟羽
 * @date 2024/3/14 9:29
 */
@SpringBootConfiguration
public class TopicConfiguration {

    @Bean
    public TopicExchange getTopicExchange(){
        return new TopicExchange("topic_exchange_one");
    }

    @Bean
    public Queue getTopicQueueOne(){
        return new Queue("topic_queue_one");
    }

    @Bean
    public Queue getTopicQueueTwo(){
        return new Queue("topic_queue_two");
    }

    @Bean
    public Queue getTopicQueueThree(){
        return new Queue("topic_queue_three");
    }
    //* 代表一个词
    //# 代表零个或者多个词
    @Bean
    public Binding getTopicBindingOne(){
        return BindingBuilder.bind(getTopicQueueOne()).to(getTopicExchange()).with("a.*");
    }

    @Bean
    public Binding getTopicBindingThree(){
        return BindingBuilder.bind(getTopicQueueThree()).to(getTopicExchange()).with("a.#");
    }


    @Bean
    public Binding getTopicBindingTwo(){
        return BindingBuilder.bind(getTopicQueueTwo()).to(getTopicExchange()).with("a.111");
    }
}
